# This is a general makefile template.
													
                               BIN_DIR = ./debug
                               TARGET = $(BIN_DIR)/like_game_server
                               C_CFLAGS = -Wall -W -Wpointer-arith -pipe -fPIC
                              
                               MACROS = -D_REENTRANT -D__USE_POSIX -DUSE_SNAP -DDESC=\"${DESC}\" -DOS_LINUX -D__linux__
                       
                                #-DSERVER_DEPLOY_FULICHENG
                                    CC = gcc
                            CPP_CFLAGS = -Wall -W -Wpointer-arith -pipe -fPIC -Wno-ignored-qualifiers
                                  MAKE = make
                                LINKER = g++
                          INCLUDE_DIRS = -I/usr/include/mongo -I/boost_1_49_0 -I/usr/include -I/usr/local/include -I/usr/lib/qt/trunk\
						-I./core -I./hy_source -I./core/third_party -I./core/hy_file_system \
						-I./hy_source/hy_db -Ihy_source/hy_net -I./hy_source/hy_system  \
						-I./hy_source/hy_system/hy_award_system -I./hy_source/hy_system/hy_battle_system \
						-I./hy_source/hy_system/hy_chat_system -I./hy_source/hy_system/hy_common_system -I./hy_source/hy_system/hy_gm_system \
						-I./hy_source/hy_system/hy_item_system -I./hy_source/hy_system/hy_map_system -I./hy_source/hy_system/hy_pet_system \
						-I./hy_source/hy_system/hy_player_system -I./hy_source/hy_system/hy_team_system -I./hy_source/hy_system/hy_user_system 
                            
                            LIBS = -lboost_thread -lboost_system -lboost_filesystem -lboost_date_time -lboost_program_options
                            LIBS = -lmongoclient
                            OPTIM_FLAG = #-O2
                                   CPP = g++
                                LFLAGS = -Wl -fPIC
                              LIB_DIRS = -L/usr/local/lib/ -L/usr/lib -L/boost_1_49_0/stage/lib

                                 VPATH = src:./ src:./core src:./hy_source src:./core/third_party src:./core/hy_file_system src:./core/third_party/json \
								 src:./hy_source/hy_db src:./hy_source/hy_net src:./core/hy_file_system\
								  ./hy_source/hy_system/hy_award_system ./hy_source/hy_system/hy_battle_system \
								 ./hy_source/hy_system/hy_chat_system ./hy_source/hy_system/hy_common_system ./hy_source/hy_system/hy_gm_system \
								 ./hy_source/hy_system/hy_item_system ./hy_source/hy_system/hy_map_system ./hy_source/hy_system/hy_pet_system \
								 ./hy_source/hy_system/hy_player_system ./hy_source/hy_system/hy_team_system ./hy_source/hy_system/hy_user_system
                            OBJECT_DIR = ./debug/obj/
                              CPPFILES = \
										core.cpp \
    file_system.cpp \
    GLog.cpp \
    hy_function.cpp \
    nedmalloc.cpp \
    tcp_session.cpp \
    time_helper.cpp \
    hy_stream.cpp \
    json_reader.cpp \
   json_value.cpp \
   json_writer.cpp \
    game_server.cpp \
    main.cpp \
    hy_db_logic.cpp \
    hy_message_dispersed_center.cpp \
    hy_network_message.cpp \
    msg_server.cpp \
    hy_battle_data.cpp \
    hy_battle_effect_data.cpp \
    hy_battle_logic.cpp \
    hy_battle_net_logic.cpp \
    hy_battle_skill_logic.cpp \
    hy_battle_unit.cpp \
    hy_buff_data.cpp \
    hy_formation_data.cpp \
    hy_formation_logic.cpp \
    hy_monster_data.cpp \
    hy_monster_db_logic.cpp \
    hy_monster_logic.cpp \
    hy_server_monster_data.cpp \
    hy_server_monster_group_data.cpp \
    hy_server_skill_data.cpp \
    hy_skill_data.cpp \
    hy_skill_db_logic.cpp \
    chat_data_json_config.cpp \
    chat_data_mgr.cpp \
    hy_chat_logic.cpp \
    hy_common_data.cpp \
    hy_common_func.cpp \
    hy_language_logic.cpp \
    hy_random.cpp \
    hy_sequence_logic.cpp \
	hy_gm_logic.cpp \
   hy_create_role_logic.cpp \
   hy_player_data.cpp \
   hy_player_db_logic.cpp \
   hy_player_logic.cpp \
   hy_player_server_logic.cpp \
   hy_reg_role_data.cpp \
   hy_server_player_data.cpp \
	hy_user_logic.cpp																																																																		
                                CFILES = 

# To use 'make debug=0' build release edition.
ifdef debug
	ifeq ("$(origin debug)", "command line")
		IS_DEBUG = $(debug)
	endif
else
	IS_DEBUG = 1
endif
ifndef IS_DEBUG
	IS_DEBUG = 1
endif
ifeq ($(IS_DEBUG), 1)
	OPTIM_FLAG += -g3
else
	MACROS += -DNDEBUG
endif

# To use 'make publish=0' build release edition.
ifdef publish 
	ifeq ("$(origin publish)", "command line")
		IS_PUB = $(publish)
	endif
else
	IS_PUB = 0
endif
ifeq ($(IS_PUB), 1)
	MACROS += -DPUBLISH
endif

# To use 'make quiet=1' all the build command will be hidden.
# To use 'make quiet=0' all the build command will be displayed.
ifdef quiet
	ifeq ("$(origin quiet)", "command line")
		QUIET = $(quiet)
	endif
endif
ifeq ($(QUIET), 1)
	Q = @
else
	Q =
endif

OBJECTS := $(addprefix $(OBJECT_DIR), $(notdir $(CPPFILES:%.cpp=%.o)))
OBJECTS += $(addprefix $(OBJECT_DIR), $(notdir $(CFILES:%.c=%.o)))

CALL_CFLAGS := $(C_CFLAGS) $(INCLUDE_DIRS) $(MACROS) $(OPTIM_FLAG)
CPPALL_CFLAGS := $(CPP_CFLAGS) $(INCLUDE_DIRS) $(MACROS) $(OPTIM_FLAG)
LFLAGS += $(OPTIM_FLAG)   $(LIB_DIRS)$(LIBS)

all: checkdir $(TARGET)

$(TARGET): $(OBJECTS)
	$(Q)$(LINKER) -o $@ $(OBJECTS) $(strip $(LFLAGS))

$(OBJECT_DIR)%.o:%.cpp
	$(Q)$(CPP) $(strip $(CPPALL_CFLAGS)) -c $< -o $@

$(OBJECT_DIR)%.o:%.c
	$(Q)$(CC) $(strip $(CALL_CFLAGS)) -c $< -o $@

checkdir:
	@if ! [ -d "$(BIN_DIR)" ]; then \
		mkdir $(BIN_DIR) ; \
		fi
	@if ! [ -d "$(OBJECT_DIR)" ]; then \
		mkdir $(OBJECT_DIR); \
		fi
clean:
	$(Q)rm -f $(OBJECTS)
cleanall: clean
	$(Q)rm -f $(TARGET)

.PHONY: all clean cleanall checkdir
